<template>
  <div class="fsize">
    <el-row :gutter="20">
      <el-col :span="3"><div >编号</div></el-col>
      <el-col :span="3"><div >医生姓名</div></el-col>
      <el-col :span="3"><div >科室</div></el-col>
      <el-col :span="3"><div >价格</div></el-col>
      <el-col :span="8"><div >操作</div></el-col>
    </el-row>
    <hr>
    <div class="wrap_item" v-for="order in orinfo">
      <el-row :gutter="20" v-if="order.id != 1" >
        <el-col :span="3"><div >{{order.id}}</div></el-col>
        <el-col :span="3"><div >{{order.name}}</div></el-col>
        <el-col :span="3"><div >{{order.type}}</div></el-col>
        <el-col :span="3"><div >{{order.price}}</div></el-col>
        <el-col :span="8">
          <el-button type="primary" @click="toDetail(order.id)">删除</el-button>
          <el-button type="primary" @click="Detail(order.phonenumber)">修改价格</el-button>
          <el-dialog title="医生回复" :visible.sync="dialogFormVisible" width="450px">
            <el-form :model="form">
              <el-form-item label="价格" :label-width="formLabelWidth">
                <el-input v-model="price">
                </el-input>
              </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
              <el-button @click="dialogFormVisible = false">取 消</el-button>
              <el-button type="primary" @click="toUpdate" >确 定</el-button>
            </div>
          </el-dialog>
        </el-col>
        <!--<el-col :span="6"><div >{{order.diagnosis}}</div></el-col>-->
      </el-row>
      <hr v-if="order.id != 1">
    </div>
  </div>
</template>

<script>
  export default {
    name: "deleteDoctor",
    data() {
      return {
        orinfo: [],
        formLabelWidth: '80px',
        dialogFormVisible: false,
        price: '',
      }
    },
    methods : {
      getList: function () {
        this.$ajax.get('http://47.75.110.31:8080/dcinfo/findAll')
          .then(response => {
            this.orinfo = response.data;
          })
      },
      toDetail(orderid) {
        this.$ajax.get('http://47.75.110.31:8080/dcinfo/delete?id='+orderid)
          .then(response => {
            this.orinfo = response.data;
            location.reload();
          })
      },
    toUpdate() {
      var orderId = localStorage.getItem("orderId");
      this.$ajax.post('http://47.75.110.31:8080/dcinfo/updatePrice?phonenumber='+orderId+'&price='+this.price,
        {

          headers: {
            'Content-Type': 'application/json;charset=UTF-8'
          }
        }
      ).then(response => {
        console.log(response.data);
        if (response.data === "success") {
          this.$message({
            message: '恭喜你添加成功',
            type: 'success'
          });
          location.reload();
        }
      })
    },
      Detail (orderid) {
        this.dialogFormVisible = true;
        localStorage.setItem("orderId",orderid);
        console.log(orderid);
      },
  },
    mounted() {
      this.getList();
    }
  }
</script>

<style scoped>
  .fsize{
    font-size: 14px;
  }
</style>
